home *** CD-ROM | disk | FTP | other *** search
Wrap
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAWBxHsWkYu9yBertEIMndPBQK84YzabrmjY1XhCgn1E5HpVj9IxS1br5Yr2ddJoJNXEp9pVQ_-dU2ZQ" type="text/javascript"></script> <script type="text/javascript"> //*********************** //* Declare variables * //*********************** var xmlURL = 'CitySearchResults.xml'; var map = null; var geocoder = null; var selectedStation = null; var markerArray = []; var markerTypeArray = []; var markerLatArray = []; var markerLongArray = []; var lastMarker; var lastMarkerType; //********************************** //* Create icons for map markers * //********************************** var iconGreen = new GIcon(); iconGreen.image = "Images/mm_20_green.png"; iconGreen.iconSize = new GSize(12, 20); iconGreen.iconAnchor = new GPoint(6, 20); var iconBlue = new GIcon(); iconBlue.image = "Images/mm_20_blue.png"; iconBlue.iconSize = new GSize(12, 20); iconBlue.iconAnchor = new GPoint(6, 20); function load() { //**************************** //* Add markers to the map * //**************************** var xml = GXml.parse("[XML]"); var markers = xml.documentElement.getElementsByTagName("aws:station"); //******************** //* Create the map * //******************** map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(markers[0].getAttribute("latitude"), markers[0].getAttribute("longitude")), 10); geocoder = new GClientGeocoder(); //*************************************** //* Add markers found in returned XML * //*************************************** for (var i = 0; i < markers.length; i++) { var lat = parseFloat(markers[i].getAttribute("latitude")); var long = parseFloat(markers[i].getAttribute("longitude")); var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")), parseFloat(markers[i].getAttribute("longitude"))); var marker = createMarker(point, markers[i].getAttribute("name"), markers[i].getAttribute("city"), markers[i].getAttribute("state"), markers[i].getAttribute("country"), markers[i].getAttribute("station-type"), markers[i].getAttribute("id"), i + 1, lat, long); map.addOverlay(marker); markerArray[i] = marker; markerTypeArray[i] = markers[i].getAttribute("station-type") markerLatArray[i] = markers[i].getAttribute("latitude") markerLongArray[i] = markers[i].getAttribute("longitude") } } function createMarker(point, stationName, stationCity, stationState, stationCountry, stationType, stationID, markerCount, lat, long) { //************************************************************ //* Set the marker color based on the weather station type * //************************************************************ if (stationState == null) stationState = ""; if (stationCountry == null) stationCountry = ""; switch (stationType) { case 'NWS': var marker = new GMarker(point, { title: stationName + "\n" + stationCity + ", " + stationState + stationCountry, icon: iconBlue}); break; default: var marker = new GMarker(point, { title: stationName + "\n" + stationCity + ", " + stationState + stationCountry, icon: iconGreen}); break; } //****************************** //* Add a marker click event * //****************************** GEvent.addListener(marker, 'click', function() { document.getElementById('WWSelectedCity').innerHTML = stationID; resetLastMarkerImage(); marker.setImage('Images/mm_20_red.png'); if (stationType == null) stationType = "WeatherBug"; lastMarkerType = stationType; lastMarker = marker; map.panTo(new GLatLng(lat, long)); }); return marker; } function setMapCenter(stationLatitude, stationLongitude) { map.panTo(new GLatLng(stationLatitude, stationLongitude)); resetLastMarkerImage(); for (var i = 0; i < markerArray.length; i++) { if (markerLatArray[i] == stationLatitude) { if (markerLongArray[i] == stationLongitude) { lastMarkerType = markerTypeArray[i]; if (lastMarkerType == null) lastMarkerType = "WeatherBug"; lastMarker = markerArray[i]; } } } lastMarker.setImage('Images/mm_20_red.png'); } function resetLastMarkerImage() { if (lastMarkerType != null) { if (lastMarkerType.length > 0) { if (lastMarkerType == "NWS") { lastMarker.setImage('Images/mm_20_blue.png'); } else { lastMarker.setImage('Images/mm_20_green.png'); } } } } function ignoreErrors() { return true; } window.onerror = ignoreErrors; </script> </head> <body onload="load()" onunload="GUnload()" STYLE="padding: 0px; margin: 0px; overflow: hidden;"> <div id="map" style="width: 100%; height: 100%;"></div><DIV ID="WWSelectedCity" STYLE="display:none;"></DIV><DIV ID="ResetCenter" STYLE="display:none;"></DIV> </body> </html>